#pragma once

#include "OMIT_MeshForwardDecl.h"

namespace OMIT_NAMESPACE
{
	template<typename Traits>
	std::vector<MeshTraits_H<Traits>*> TEdge<Traits>::AdjOutHalfEdges() {
		std::vector<TH*> hs;
		auto* h01 = HalfEdge(); // v0 => v1
		for (auto* h : h01->RotateNext()->RotateNextTo(h01))
			hs.push_back(h);
		for (auto* h : h01->Next()->RotateNextTo(h01->Pair()))
			hs.push_back(h);
		return hs;
	}

	template<typename Traits>
	std::vector<const MeshTraits_H<Traits>*> TEdge<Traits>::AdjOutHalfEdges() const {
		std::vector<const TH*> hs;
		auto* h01 = HalfEdge(); // v0 => v1
		for (auto* h : h01->RotateNext()->RotateNextTo(h01))
			hs.push_back(h);
		for (auto* h : h01->Next()->RotateNextTo(h01->Pair()))
			hs.push_back(h);
		return hs;
	}

	template<typename Traits>
	std::set<MeshTraits_V<Traits>*> TEdge<Traits>::AdjVertices() {
		std::set<TV*> vertices;
		for (auto* h : AdjOutHalfEdges())
			vertices.insert(h->End());
		return vertices;
	}

	template<typename Traits>
	std::set<const MeshTraits_V<Traits>*> TEdge<Traits>::AdjVertices() const {
		std::set<const TV*> vertices;
		for (auto* h : AdjOutHalfEdges())
			vertices.insert(h->End());
		return vertices;
	}

	template<typename Traits>
	std::vector<MeshTraits_E<Traits>*> TEdge<Traits>::AdjEdges() {
		std::vector<TE*> edges;
		for (auto* h : AdjOutHalfEdges())
			edges.push_back(h->Edge());
		return edges;
	}

	template<typename Traits>
	std::vector<const MeshTraits_E<Traits>*> TEdge<Traits>::AdjEdges() const {
		std::vector<const TE*> edges;
		for (auto* h : AdjOutHalfEdges())
			edges.push_back(h->Edge());
		return edges;
	}
}
